@extends('layouts.default')
@section('content')
@include('modules.thanhmenu')
<?php
$idbm = Session::get('infor.idbm')[0];
$check = false;

if (count($de_tai) == 3) {
    $check = true;
    $tbmphancong = new TBMPhanCongHDXD();
    $ms_hd = $de_tai[0]->ma_so_hoi_dong;
    $cb_hd = $tbmphancong->getCanBoHD($de_tai[0]->id, $idbm);
    $ds_cb = $tbmphancong->getDSCanBo($de_tai[0]->id, $idbm);
} else {
    $tbmphancong = new TBMPhanCongHDXD();
    $ms_hd = $tbmphancong->getMaSoHD();
    $cb_hd = $tbmphancong->getCanBoHD($de_tai[0]->id, $idbm);
    $ds_cb = $tbmphancong->getDSCanBo($de_tai[0]->id, $idbm);
}
?>
<!--Requirement jQuery-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!--Load Script and Stylesheet -->
<script type="text/javascript" src="<?= URL ?>public/datetimepicker/jquery.simple-dtpicker.js"></script>
<link type="text/css" href="<?= URL ?>public/datetimepicker/jquery.simple-dtpicker.css" rel="stylesheet" />
<!---->

<style type="text/css">
    body { background-color: #ffffff; padding-left: 1%; padding-bottom: 100px; }
    footer{font-size:small;position:fixed;right:5px;bottom:5px;}
</style>
<form name="frmPhanCong" action="<?= URL; ?>tbmphancongHD" method="post" onsubmit="return checkFormPhanCong(this)">
    <?= Form::token(); ?>
    <table cellspacing="0" cellpadding="0" width="100%" class="danhsachhp">
        <tr>
            <td class="cm_footer btop brt">Phân Công Hội đồng số <?= $ms_hd ?>
                <input type="hidden" name="msHoiDong" value="<?= $ms_hd ?>"/>
                <input type="hidden" name="idDeTaiLV" value="<?= $de_tai[0]->id ?>"/>
            </td>
        </tr>
        <tr>
            <td class="brt">
                Đề tài: <?= $de_tai[0]->ten_de_tai ?>
            </td>
        </tr>
        <tr>
            <td class="brt">
                Chủ tịch:&nbsp;
                <select name="chuTich">
                    <option value="">--Chọn cán bộ chủ tịch--</option>
                    <?php
                    foreach ($ds_cb as $cb) {
                        ?>
                        <option value="<?= $cb->id ?>" <?php if ($check) {
                        if ($de_tai[0]->id_can_bo == $cb->id) echo "selected='selected'";
                    } ?>><?= $cb->mscb ?> - <?= $cb->ho . " " . $cb->ten ?></option>
                        <?php
                    }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="brt">
                Ủy viên:&nbsp;
                <select width="400px" name="uyVien">
                    <option value="">--Chọn cán bộ ủy viên--</option>
                    <?php
                    foreach ($ds_cb as $cb) {
                        ?>
                        <option value="<?= $cb->id ?>" <?php if ($check) {
                        if ($de_tai[1]->id_can_bo == $cb->id) echo "selected='selected'";
                    } ?>><?= $cb->mscb ?> - <?= $cb->ho . " " . $cb->ten ?></option>
    <?php
}
?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="brt">
                Thư ký:&nbsp;
                <input type="text" name="tenThuKy" value="<?= $cb_hd[0]->mscb ?> - <?= $cb_hd[0]->ho . " " . $cb_hd[0]->ten ?>" readonly="readonly"/>
                <input type="hidden" name="thuKiLV" value="<?= $cb_hd[0]->id ?>"/>
            </td>
        </tr>
        <tr>
            <td class="brt">
                Thời gian xét duyệt: 
                <input type="text" name="ngayXetDuyet" id="ngayXetDuyetId" value="<?php if ($check) {echo date("H:i d/m/Y", strtotime($de_tai[0]->thoi_gian_xet_duyet));} ?>"/>
            </td>
        </tr>
        <tr>
            <td class="brt">
                <input type="submit" class="button_css" name="btnXacNhan" value="Xác nhận"/>&nbsp;
                <input type="reset" class="button_css" name="btnLamLai" value="Làm lại"/>
            </td>
        </tr>
    </table>
</form>
<script type="text/javascript">
$(function() {
                        $('*[name=ngayXetDuyet]').appendDtpicker({
                            "inline": true,
                            "dateFormat": "h:m DD/MM/yyyy"
                        });
                    });
    function checkFormPhanCong(string)
    {
        var chutich = string.chuTich.value;
        var uyvien = string.uyVien.value;
        if (chutich == "")
        {
            alert("Vui lòng chọn cán bộ chủ tịch!");
            string.chuTich.focus();
            return false;
        }
        else if (uyvien == "")
        {
            alert("Vui lòng chọn cán bộ ủy viên!");
            string.uyVien.focus();
            return false;
        }
        else if (chutich == uyvien)
        {
            alert("Chủ tịch và ủy viên không được cùng chung cán bộ!");
            string.uyVien.focus();
            return false;
        }
        else {
            return true;
        }
    }
</script>
@stop

